<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c"       uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<%=basePath%>" />
     <meta http-equiv="content-Type" content="text/html; charset=utf-8" />
    <title>tueye发表文章-tueye发表文章-tueye专业的图片欣赏交流社区</title>
   
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
<link href="<%=path %>/themes/css/index.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/themes/css/regis.css" rel="stylesheet" type="text/css" /> 

<script type="text/javascript" src="<%=path %>/script/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/script/jquery.cookie.js"></script>
 
<style type="text/css">
.warning{

}
.code{
  font-size:12px;
}
#loginsuccess{
 	  clear:both;
}
#loginsuccess a{
color:#6666CC; text-decoration:none;font-size:14px;
}
#loginsuccess  a:hover{
background:#6666CC none repeat scroll 0 0;color:#FFFFFF;padding:3px 1px 0;
}
 
</style>
  <script type="text/javascript">   
$(function(){  
	    $('form :input').blur(function(){
	         var id = $(this).attr("id");
             $(this).removeClass("warning").parents("td")
			 .find("span.error").remove()
			 .end()
			 .find("span.ok").remove();

		     var $listItem =  $(this).parents("td").find("span:last");
		     
		     
			 //验证email和昵称
			  if( id == 'Email' ){
				if($(this).attr("value") == null || $(this).attr("value") == ''){
                      var errorMsg = '请输入登录帐号！';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
				}else{
                       var okMsg = '';
                       $(this).parent().next().text(okMsg)
                       }
			 
				
			    }
			    
			     //验证密码
			 if( id == 'password1' ){
				if($(this).attr("value") == null || $(this).attr("value") == ''){
                      var errorMsg = '请输入登录密码!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
				}else{
                       var okMsg = '';
                       $(this).parent().next().text(okMsg)
                       }
			 
				
			 }
			 		 
     })//end blur
 
 
 //提交，最终验证。
	$("#tijiao").bind("click", function(){
	     
	       
			$(":input").trigger('blur');
		
			var numWarning = $('.warning',$('form')).length;
			
            if(numWarning){
			    var errorFieldList = [];
                $(".warning").each(function(){
					errorFieldList.push( $(this).prev("span").text() );
				})
				
				return false;
			}  
			
			var Email = $('#Email').val();
			
			var password =  $('#password1').val();
			var sendData= "Email="+encodeURIComponent(Email)+"&password1="+password;
			
			$.ajax({
            type:"POST",
            url: "<%=request.getContextPath()%>/userlogin.do?action=login", 
            dataType:'html', //接受数据格式
            async: false,
            data: sendData,
            success: function(data){ 
             var obj=eval("("+data+")");  
                  if(data=='0'){ 
                    $('#Email').parent().next().html("<font color='red'>您输入的用户名有误，请重新输入!</font>");
                  }else if(data=='2'){
                    //显示在验证码后面
                    $('#password1').parent().next().html("<font color='red'>您输入的密码有误，请重新输入，请注意大小写!</font>");
                  }else if(obj.target == '1'){
                      $('#mainbody').hide();
                      $('#loginsuccess').append("<a href='"+obj.yu+"'>返回原来的页面</a>  &nbsp;&nbsp;&nbsp;&nbsp;<a href='<%=path%>/pages/index.html'>返回首页</a>");
                      //能过验证了以后，将cookie设置到用户
                      if($('#check').attr("checked")==true)
                        {
                            $.cookie('useremail', Email, { expires: 30 }); 
                        }
                   }
                }
			
			,
           error:function(data){
             alert(data);
           }
	
	})
	  
	 
		 })
		
		    
		 
	})
	
  </script>
</head>

<body>
    <%@ include file="../../../../common/header.jsp" %>
<div id="container">
 <div id="loginsuccess"　style="display:none;">
    
 </div>
<div id="mainbody"> 
   <h1>登录TuEye网</h1> 
	<form method="post" action="" name="userlogin" id="userlogin" >
	<table>
	 <tr><td colspan="2">
	 </td></tr>
	 <tr><td width="20%"  align="right">
	  Email:
	 </td><td align="left" width="30%"><input type="text" name="Email" id="Email"/></td><td class="regtip" align="right"></td></tr>
	  <tr><td width="20%"  align="right">
	 &nbsp;
	 </td><td align="left" width="30%"><font color="gray">你可用email或昵称登录
	 </font></td></tr>
	  
	 <tr><td  width="20%" align="right">
	   密码:
	 </td><td align="left"><input type="password"  name="password" id="password1" value=""/></td><td class="regtip"></td></tr>
 
	  <tr><td  width="20%" align="right">
	   &nbsp;
	 </td><td align="left"> <input type="checkbox" id="check" checked="checked" /><font color="gray"> 一个月之内免登录</font></td><td class="regtip"></td></tr>
	 
	 <tr> <td colspan="3" align="center"><input type="button"  id="tijiao" value="登&nbsp;录" /></td></tr>
	</table>
	</form>
 </div> </div>
<%@ include file="../../../../common/footer.jsp" %>
</body>
</html>

